package com.demo.controller;


import com.demo.domain.CtTransfer;
import com.demo.service.impl.CtTransferServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CtTransfer)表控制层
 *
 * @author makejava
 * @since 2021-07-07 10:46:33
 */
@RestController
public class CtTransferController {
    /**
     * 服务对象
     */
    @Resource
    private CtTransferServiceImpl ctTransferService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne4")
    public CtTransfer selectOne(Integer id) {
        return this.ctTransferService.queryById(id);
    }
    @GetMapping("selectAll4")
    public List<CtTransfer> selectAll(){
        return this.ctTransferService.queryAllByLimit();
    }
    @GetMapping("insertById4")
    public CtTransfer insertById(Integer is_face,String title,String price,String banner_images,String content,String person_name,String person_mobile){
        CtTransfer transfer = new CtTransfer();
        transfer.setTTitle(title);
        if(is_face==1){
            transfer.setTSale("0");
        }else{
            transfer.setTSale(price);
        }

        transfer.setTImg(banner_images);
        transfer.setTContent(content);
        transfer.setTPerson(person_name);
        transfer.setTPhone(person_mobile);
        return this.ctTransferService.insert(transfer);
    }
    @PostMapping("updateById4")
    public CtTransfer updateById(CtTransfer ctTransfer){
        return this.ctTransferService.update(ctTransfer);
    }
    @PostMapping("deleteById4/{id}")
    public boolean deleteById(@PathVariable int id){
        return this.ctTransferService.deleteById(id);
    }
}